import { _ as __easycom_1 } from './uv-loading-icon.DuNkB54M.js';
import { aL as createAnimation$1, _ as _export_sfc, m as mpMixin, a as mixin, c as createBlock, e as createCommentVNode, o as openBlock, w as withCtx, r as renderSlot, n as normalizeStyle, f as normalizeClass, i as index$g, j as resolveEasycom, k as resolveDynamicComponent, M as withModifiers, J as __easycom_0, b as createVNode, s as index$i, t as createTextVNode, u as toDisplayString } from './index-Cc4oxzDN.js';

// const defaultOption = {
// 	duration: 300,
// 	timingFunction: 'linear',
// 	delay: 0,
// 	transformOrigin: '50% 50% 0'
// }



class MPAnimation {
	constructor(options, _this) {
		this.options = options;
		// 在iOS10+QQ小程序平台下，传给原生的对象一定是个普通对象而不是Proxy对象，否则会报parameter should be Object instead of ProxyObject的错误
		this.animation = createAnimation$1({
			...options
		});
		this.currentStepAnimates = {};
		this.next = 0;
		this.$ = _this;

	}

	_nvuePushAnimates(type, args) {
		let aniObj = this.currentStepAnimates[this.next];
		let styles = {};
		if (!aniObj) {
			styles = {
				styles: {},
				config: {}
			};
		} else {
			styles = aniObj;
		}
		if (animateTypes1.includes(type)) {
			if (!styles.styles.transform) {
				styles.styles.transform = '';
			}
			let unit = '';
			if(type === 'rotate'){
				unit = 'deg';
			}
			styles.styles.transform += `${type}(${args+unit}) `;
		} else {
			styles.styles[type] = `${args}`;
		}
		this.currentStepAnimates[this.next] = styles;
	}
	_animateRun(styles = {}, config = {}) {
		let ref = this.$.$refs['ani'].ref;
		if (!ref) return
		return new Promise((resolve, reject) => {
			nvueAnimation.transition(ref, {
				styles,
				...config
			}, res => {
				resolve();
			});
		})
	}

	_nvueNextAnimate(animates, step = 0, fn) {
		let obj = animates[step];
		if (obj) {
			let {
				styles,
				config
			} = obj;
			this._animateRun(styles, config).then(() => {
				step += 1;
				this._nvueNextAnimate(animates, step, fn);
			});
		} else {
			this.currentStepAnimates = {};
			typeof fn === 'function' && fn();
			this.isEnd = true;
		}
	}

	step(config = {}) {

		this.animation.step(config);






		return this
	}

	run(fn) {

		this.$.animationData = this.animation.export();
		this.$.timer = setTimeout(() => {
			typeof fn === 'function' && fn();
		}, this.$.durationTime);








	}
}


const animateTypes1 = ['matrix', 'matrix3d', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scale3d',
	'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'translate', 'translate3d', 'translateX', 'translateY',
	'translateZ'
];
const animateTypes2 = ['opacity', 'backgroundColor'];
const animateTypes3 = ['width', 'height', 'left', 'right', 'top', 'bottom'];
animateTypes1.concat(animateTypes2, animateTypes3).forEach(type => {
	MPAnimation.prototype[type] = function(...args) {

		this.animation[type](...args);




		return this
	};
});

function createAnimation(option, _this) {
	if(!_this) return
	clearTimeout(_this.timer);
	return new MPAnimation(option, _this)
}

/**
	* transition  动画组件
	* @description
	* @tutorial
	* @property {Boolean}	show	控制组件显示或关闭 （默认 false ）
	* @property {Array | String	}	mode	内置过渡动画类型 （默认 'fade' ）
	* @value fade 渐隐渐出过渡
	* @value slide-top 由上至下过渡
	* @value slide-bottom 由下至上过渡
	* @value slide-left 由左至右过渡
	* @value slide-right 由右至左过渡
	* @value zoom-in 由小到大过渡
	* @value zoom-out 由大到小过渡
	* @property {String | Number}	duration	动画的执行时间，单位ms （默认 300 ）
	* @property {String} timingFunction	使用的动画过渡函数 （默认 'ease-out' ）
	* @property {Object} customStyle	自定义样式
	* @property {String} customClass	自定义类名
	* @event {Function} click 点击组件触发	
	* @event {Function} change	过渡动画结束时触发	
	* @example 
	*/
	const _sfc_main$3 = {
		name: 'uv-transition',
		mixins: [mpMixin,mixin],
		emits:['click','change'],
		props: {
			// 是否展示组件
			show: {
				type: Boolean,
				default: false
			},
			// 使用的动画模式
			mode: {
				type: [Array, String, null],
				default() {
					return 'fade'
				}
			},
			// 动画的执行时间，单位ms
			duration: {
				type: [String, Number],
				default: 300
			},
			// 使用的动画过渡函数
			timingFunction: {
				type: String,
				default: 'ease-out'
			},
			customClass: {
				type: String,
				default: ''
			},
			// nvue模式下 是否直接显示，在uv-list等cell下面使用就需要设置
			cellChild: {
				type: Boolean,
				default: false
			}
		},
		data(){
			return {
				isShow: false,
				transform: '',
				opacity: 1,
				animationData: {},
				durationTime: 300,
				config: {}
			}
		},
		watch: {
			show: {
				handler(newVal) {
					if (newVal) {
						this.open();
					} else {
						// 避免上来就执行 close,导致动画错乱
						if (this.isShow) {
							this.close();
						}
					}
				},
				immediate: true
			}
		},
		computed: {
			// 初始化动画条件
			transformStyles() {
				const style = {
					transform: this.transform,
					opacity: this.opacity,
					...this.$uv.addStyle(this.customStyle),
					'transition-duration': `${this.duration / 1000}s`
				};
				return this.$uv.addStyle(style,'string');
			}
		},
		created() {
			// 动画默认配置
			this.config = {
				duration: this.duration,
				timingFunction: this.timingFunction,
				transformOrigin: '50% 50%',
				delay: 0
			};
			this.durationTime = this.duration;
		},
		methods: {
			/**
			 *  ref 触发 初始化动画
			 */
			init(obj = {}) {
				if (obj.duration) {
					this.durationTime = obj.duration;
				}
				this.animation = createAnimation(Object.assign(this.config, obj),this);
			},
			/**
			 * 点击组件触发回调
			 */
			onClick() {
				this.$emit('click', {
					detail: this.isShow
				});
			},
			/**
			 * ref 触发 动画分组
			 * @param {Object} obj
			 */
			step(obj, config = {}) {
				if (!this.animation) return;
				for (let i in obj) {
					try {
						if(typeof obj[i] === 'object'){
							this.animation[i](...obj[i]);
						}else {
							this.animation[i](obj[i]);
						}
					} catch (e) {
						console.error(`方法 ${i} 不存在`);
					}
				}
				this.animation.step(config);
				return this;
			},
			/**
			 *  ref 触发 执行动画
			 */
			run(fn) {
				if (!this.animation) return;
				this.animation.run(fn);
			},
			// 开始过度动画
			open() {
				clearTimeout(this.timer);
				this.transform = '';
				this.isShow = true;
				let { opacity, transform } = this.styleInit(false);
				if (typeof opacity !== 'undefined') {
					this.opacity = opacity;
				}
				this.transform = transform;
				// 确保动态样式已经生效后，执行动画，如果不加 nextTick ，会导致 wx 动画执行异常
				this.$nextTick(() => {
					// TODO 定时器保证动画完全执行，目前有些问题，后面会取消定时器
					this.timer = setTimeout(() => {
						this.animation = createAnimation(this.config, this);
						this.tranfromInit(false).step();








						this.animation.run();



						this.opacity = 1;


						this.$emit('change', {
							detail: this.isShow
						});


						this.transform = '';


					}, 20);
				});
			},
			// 关闭过渡动画
			close(type) {
				if (!this.animation) return;
				this.tranfromInit(true)
					.step()
					.run(() => {
						this.isShow = false;
						this.animationData = null;
						this.animation = null;
						let { opacity, transform } = this.styleInit(false);
						this.opacity = opacity || 1;
						this.transform = transform;
						this.$emit('change', {
							detail: this.isShow
						});
					});
			},
			// 处理动画开始前的默认样式
			styleInit(type) {
				let styles = {
					transform: ''
				};
				let buildStyle = (type, mode) => {
					if (mode === 'fade') {
						styles.opacity = this.animationType(type)[mode];
					} else {
						styles.transform += this.animationType(type)[mode] + ' ';
					}
				};
				if (typeof this.mode === 'string') {
					buildStyle(type, this.mode);
				} else {
					this.mode.forEach(mode => {
						buildStyle(type, mode);
					});
				}
				return styles
			},
			// 处理内置组合动画
			tranfromInit(type) {
				let buildTranfrom = (type, mode) => {
					let aniNum = null;
					if (mode === 'fade') {
						aniNum = type ? 0 : 1;
					} else {
						aniNum = type ? '-100%' : '0';
						if (mode === 'zoom-in') {
							aniNum = type ? 0.8 : 1;
						}
						if (mode === 'zoom-out') {
							aniNum = type ? 1.2 : 1;
						}
						if (mode === 'slide-right') {
							aniNum = type ? '100%' : '0';
						}
						if (mode === 'slide-bottom') {
							aniNum = type ? '100%' : '0';
						}
					}
					this.animation[this.animationMode()[mode]](aniNum);
				};
				if (typeof this.mode === 'string') {
					buildTranfrom(type, this.mode);
				} else {
					this.mode.forEach(mode => {
						buildTranfrom(type, mode);
					});
				}
				return this.animation;
			},
			animationType(type) {
				return {
					fade: type ? 1 : 0,
					'slide-top': `translateY(${type ? '0' : '-100%'})`,
					'slide-right': `translateX(${type ? '0' : '100%'})`,
					'slide-bottom': `translateY(${type ? '0' : '100%'})`,
					'slide-left': `translateX(${type ? '0' : '-100%'})`,
					'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
					'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
				}
			},
			// 内置动画类型与实际动画对应字典
			animationMode() {
				return {
					fade: 'opacity',
					'slide-top': 'translateY',
					'slide-right': 'translateX',
					'slide-bottom': 'translateY',
					'slide-left': 'translateX',
					'zoom-in': 'scale',
					'zoom-out': 'scale'
				}
			},
			// 驼峰转中横线
			toLine(name) {
				return name.replace(/([A-Z])/g, '-$1').toLowerCase()
			}
		}
	};

function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_v_uni_view = index$g;

  return ($data.isShow)
    ? (openBlock(), createBlock(_component_v_uni_view, {
        key: 0,
        ref: "ani",
        animation: $data.animationData,
        class: normalizeClass($props.customClass),
        style: normalizeStyle($options.transformStyles),
        onClick: $options.onClick
      }, {
        default: withCtx(() => [
          renderSlot(_ctx.$slots, "default")
        ]),
        _: 3
      }, 8, ["animation", "class", "style", "onClick"]))
    : createCommentVNode("", true)
}
const __easycom_5$2 = /*#__PURE__*/_export_sfc(_sfc_main$3, [['render',_sfc_render$3]]);

const props$1 = {
	props: {
		// 是否显示遮罩
		show: {
			type: Boolean,
			default: false
		},
		// 层级z-index
		zIndex: {
			type: [String, Number],
			default: 10070
		},
		// 遮罩的过渡时间，单位为ms
		duration: {
			type: [String, Number],
			default: 300
		},
		// 不透明度值，当做rgba的第四个参数
		opacity: {
			type: [String, Number],
			default: 0.5
		},
		...uni.$uv?.props?.overlay
	}
};

/**
	 * overlay 遮罩
	 * @description 创建一个遮罩层，用于强调特定的页面元素，并阻止用户对遮罩下层的内容进行操作，一般用于弹窗场景
	 * @tutorial https://www.uvui.cn/components/overlay.html
	 * @property {Boolean}			show		是否显示遮罩（默认 false ）
	 * @property {String | Number}	zIndex		zIndex 层级（默认 10070 ）
	 * @property {String | Number}	duration	动画时长，单位毫秒（默认 300 ）
	 * @property {String | Number}	opacity		不透明度值，当做rgba的第四个参数 （默认 0.5 ）
	 * @property {Object}			customStyle	定义需要用到的外部样式
	 * @event {Function} click 点击遮罩发送事件
	 * @example <uv-overlay :show="show" @click="show = false"></uv-overlay>
	 */
	const _sfc_main$2 = {
		name: "uv-overlay",
		emits: ['click'],
		mixins: [mpMixin, mixin, props$1],
		watch: {
			show(newVal){

				if(newVal){
					document.querySelector('body').style.overflow = 'hidden';
				}else {
					document.querySelector('body').style.overflow = '';
				}

			}
		},
		computed: {
			overlayStyle() {
				const style = {
					position: 'fixed',
					top: 0,
					left: 0,
					right: 0,
					zIndex: this.zIndex,
					bottom: 0,
					'background-color': `rgba(0, 0, 0, ${this.opacity})`
				};
				return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
			}
		},
		methods: {
			clickHandler() {
				this.$emit('click');
			},
			clear() {}
		}
	};

function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_uv_transition = resolveEasycom(resolveDynamicComponent("uv-transition"), __easycom_5$2);

  return (openBlock(), createBlock(_component_uv_transition, {
    show: _ctx.show,
    mode: "fade",
    "custom-class": "uv-overlay",
    duration: _ctx.duration,
    "custom-style": $options.overlayStyle,
    onClick: $options.clickHandler,
    onTouchmove: withModifiers($options.clear, ["stop","prevent"])
  }, {
    default: withCtx(() => [
      renderSlot(_ctx.$slots, "default", {}, undefined, true)
    ]),
    _: 3
  }, 8, ["show", "duration", "custom-style", "onClick", "onTouchmove"]))
}
const __easycom_5$1 = /*#__PURE__*/_export_sfc(_sfc_main$2, [['render',_sfc_render$2],['__scopeId',"data-v-9cc2c1b3"]]);

const props = {
	props: {
		// 背景颜色（默认transparent）
		bgColor: {
			type: String,
			default: 'transparent'
		},
		// 分割槽高度，单位px（默认20）
		height: {
			type: [String, Number],
			default: 20
		},
		// 与上一个组件的距离
		marginTop: {
			type: [String, Number],
			default: 0
		},
		// 与下一个组件的距离
		marginBottom: {
			type: [String, Number],
			default: 0
		},
		...uni.$uv?.props?.gap
	}
};

/**
	 * gap 间隔槽
	 * @description 该组件一般用于内容块之间的用一个灰色块隔开的场景，方便用户风格统一，减少工作量
	 * @tutorial https://www.uvui.cn/components/gap.html
	 * @property {String}			bgColor			背景颜色 （默认 'transparent' ）
	 * @property {String | Number}	height			分割槽高度，单位px （默认 20 ）
	 * @property {String | Number}	marginTop		与前一个组件的距离，单位px（ 默认 0 ）
	 * @property {String | Number}	marginBottom	与后一个组件的距离，单位px （默认 0 ）
	 * @property {Object}			customStyle		定义需要用到的外部样式
	 * 
	 * @example <uv-gap height="80" bg-color="#bbb"></uv-gap>
	 */
	const _sfc_main$1 = {
		name: "uv-gap",
		mixins: [mpMixin, mixin,props],
		computed: {
			gapStyle() {
				const style = {
					backgroundColor: this.bgColor,
					height: this.$uv.addUnit(this.height),
					marginTop: this.$uv.addUnit(this.marginTop),
					marginBottom: this.$uv.addUnit(this.marginBottom),
				};
				return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
			}
		}
	};

function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_v_uni_view = index$g;

  return (openBlock(), createBlock(_component_v_uni_view, {
    class: "uv-gap",
    style: normalizeStyle([$options.gapStyle])
  }, null, 8, ["style"]))
}
const __easycom_2 = /*#__PURE__*/_export_sfc(_sfc_main$1, [['render',_sfc_render$1]]);

/**
	 * toast 消息提示
	 * @description 此组件表现形式类似uni的uni.showToastAPI，但也有不同的地方。
	 * @tutorial https://www.uvui.cn/components/toast.html
	 * @property {String | Number}	zIndex		toast展示时的zIndex值 (默认 10090 )
	 * @property {Boolean}			loading		是否加载中 （默认 false ）
	 * @property {String | Number}	message		显示的文字内容
	 * @property {String}			icon		图标，或者绝对路径的图片
	 * @property {String}			type		主题类型 （默认 default）
	 * @property {Boolean}			show		是否显示该组件 （默认 false）
	 * @property {Boolean}			overlay		是否显示透明遮罩，防止点击穿透 （默认 false ）
	 * @property {String}			position	位置 （默认 'center' ）
	 * @property {Object}			params		跳转的参数 
	 * @property {String | Number}  duration	展示时间，单位ms （默认 2000 ）
	 * @property {Boolean}			isTab		是否返回的为tab页面 （默认 false ）
	 * @property {String}			url			toast消失后是否跳转页面，有则跳转，优先级高于back参数 
	 * @property {Function}			complete	执行完后的回调函数 
	 * @property {Boolean}			back		结束toast是否自动返回上一页 （默认 false ）
	 * @property {Object}			customStyle	组件的样式，对象形式
	 * @event {Function} show 显示toast，如需一进入页面就显示toast，请在onReady生命周期调用
	 * @example <uv-toast ref="uToast" />
	 */
	const _sfc_main = {
		name: 'uv-toast',
		mixins: [mpMixin, mixin],
		data() {
			return {
				isShow: false,
				timer: null, // 定时器
				config: {
					message: '', // 显示文本
					type: '', // 主题类型，primary，success，error，warning，black
					duration: 2000, // 显示的时间，毫秒
					icon: true, // 显示的图标
					position: 'center', // toast出现的位置
					complete: null, // 执行完后的回调函数
					overlay: false, // 是否防止触摸穿透
					loading: false, // 是否加载中状态
				},
				tmpConfig: {}, // 将用户配置和内置配置合并后的临时配置变量
			}
		},
		computed: {
			iconName() {
				// 只有不为none，并且type为error|warning|succes|info时候，才显示图标
				if(!this.tmpConfig.icon || this.tmpConfig.icon == 'none') {
					return '';
				}
				if (['error', 'warning', 'success', 'primary'].includes(this.tmpConfig.type)) {
					return this.$uv.type2icon(this.tmpConfig.type)
				} else {
					return ''
				}
			},
			overlayStyle() {
				const style = {
					justifyContent: 'center',
					alignItems: 'center',
					display: 'flex'
				};
				// 将遮罩设置为100%透明度，避免出现灰色背景
				style.backgroundColor = 'rgba(0, 0, 0, 0)';
				return style
			},
			iconStyle() {
				const style = {};
				// 图标需要一个右边距，以跟右边的文字有隔开的距离
				style.marginRight = '4px';






				return style
			},
			// 内容盒子的样式
			contentStyle() {
				const windowHeight = this.$uv.sys().windowHeight, style = {};
				let value = 0;
				// 根据top和bottom，对Y轴进行窗体高度的百分比偏移
				if(this.tmpConfig.position === 'top') {
					value = - windowHeight * 0.25;
				} else if(this.tmpConfig.position === 'bottom') {
					value = windowHeight * 0.25;
				}
				style.transform = `translateY(${value}px)`;
				return style
			}
		},
		created() {
			// 通过主题的形式调用toast，批量生成方法函数
			['primary', 'success', 'error', 'warning', 'default', 'loading'].map(item => {
				this[item] = message => this.show({
					type: item,
					message
				});
			});
		},
		methods: {
			// 显示toast组件，由父组件通过this.$refs.xxx.show(options)形式调用
			show(options) {
				// 不将结果合并到this.config变量，避免多次调用uv-toast，前后的配置造成混乱
				this.tmpConfig = this.$uv.deepMerge(this.config, options);
				// 清除定时器
				this.clearTimer();
				this.isShow = true;
				this.timer = setTimeout(() => {
					// 倒计时结束，清除定时器，隐藏toast组件
					this.clearTimer();
					// 判断是否存在callback方法，如果存在就执行
					typeof(this.tmpConfig.complete) === 'function' && this.tmpConfig.complete();
				}, this.tmpConfig.duration);
			},
			// 隐藏toast组件，由父组件通过this.$refs.xxx.hide()形式调用
			hide() {
				this.clearTimer();
			},
			clearTimer() {
				this.isShow = false;
				// 清除定时器
				clearTimeout(this.timer);
				this.timer = null;
			}
		},






		unmounted() {
			this.clearTimer();
		}

	};

function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_uv_loading_icon = resolveEasycom(resolveDynamicComponent("uv-loading-icon"), __easycom_1);
  const _component_uv_icon = resolveEasycom(resolveDynamicComponent("uv-icon"), __easycom_0);
  const _component_uv_gap = resolveEasycom(resolveDynamicComponent("uv-gap"), __easycom_2);
  const _component_v_uni_text = index$i;
  const _component_v_uni_view = index$g;
  const _component_uv_overlay = resolveEasycom(resolveDynamicComponent("uv-overlay"), __easycom_5$1);

  return (openBlock(), createBlock(_component_v_uni_view, { class: "uv-toast" }, {
    default: withCtx(() => [
      createVNode(_component_uv_overlay, {
        show: $data.isShow,
        "custom-style": $options.overlayStyle
      }, {
        default: withCtx(() => [
          createVNode(_component_v_uni_view, {
            class: normalizeClass(["uv-toast__content", ['uv-type-' + $data.tmpConfig.type, ($data.tmpConfig.type === 'loading' || $data.tmpConfig.loading) ?  'uv-toast__content--loading' : '']]),
            style: normalizeStyle([$options.contentStyle])
          }, {
            default: withCtx(() => [
              ($data.tmpConfig.type === 'loading')
                ? (openBlock(), createBlock(_component_uv_loading_icon, {
                    key: 0,
                    mode: "circle",
                    color: "rgb(255, 255, 255)",
                    inactiveColor: "rgb(120, 120, 120)",
                    size: "25"
                  }))
                : ($data.tmpConfig.type !== 'defalut' && $options.iconName)
                  ? (openBlock(), createBlock(_component_uv_icon, {
                      key: 1,
                      name: $options.iconName,
                      size: "17",
                      color: $data.tmpConfig.type,
                      customStyle: $options.iconStyle
                    }, null, 8, ["name", "color", "customStyle"]))
                  : createCommentVNode("", true),
              ($data.tmpConfig.type === 'loading' || $data.tmpConfig.loading)
                ? (openBlock(), createBlock(_component_uv_gap, {
                    key: 2,
                    height: "12",
                    bgColor: "transparent"
                  }))
                : createCommentVNode("", true),
              createVNode(_component_v_uni_text, {
                class: normalizeClass(["uv-toast__content__text", ['uv-toast__content__text--' + $data.tmpConfig.type]]),
                style: {"max-width":"400rpx"}
              }, {
                default: withCtx(() => [
                  createTextVNode(toDisplayString($data.tmpConfig.message), 1)
                ]),
                _: 1
              }, 8, ["class"])
            ]),
            _: 1
          }, 8, ["style", "class"])
        ]),
        _: 1
      }, 8, ["show", "custom-style"])
    ]),
    _: 1
  }))
}
const __easycom_5 = /*#__PURE__*/_export_sfc(_sfc_main, [['render',_sfc_render],['__scopeId',"data-v-4fdbf213"]]);

export { __easycom_5$1 as _, __easycom_5$2 as a, __easycom_5 as b };
